import os

basedir = os.path.abspath(os.path.dirname(__file__))
print('basedir===',basedir)

class BaseConfig:
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to guess string'
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    FLASKY_MAIL_SUBJECT_PREFIX = '[Flasky]'
    FLASKY_MAIL_SENDER = '119161229@qq.com'
    FLASKY_ADMIN = os.environ.get('FLASKY_ADMIN')
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    SQLALCHEMY_ECHO = False

    # aliyun oss
    ALIYUN_OSS_ACCESS_KEY_ID = 'LTAI5tKsHGypsVpazRgmbLRm'
    ALIYUN_OSS_ACCESS_KEY_SECRET = 'YBeqokOdXpFh9Hk1Mdq9hBaob2JhUA'
    ALIYUN_OSS_ENDPOINT = 'oss-cn-hangzhou.aliyuncs.com'
    ALIYUN_OSS_BUCKET_NAME = 'knowage2025'
    ALIYUN_OSS_DOMAIN = 'knowage2025.oss-cn-hangzhou.aliyuncs.com'

    # wechat info
    WECHAT_APPID = 'wx0cac91787563e40b'
    WECHAT_SECRET = '0f28b554b8360eade6716cf01f5fde8b'

    @staticmethod
    def init_app(app):
        pass


class DevelopmentConfig(BaseConfig):
    DEBUG = True
    MAIL_SERVER = 'smtp.qq.com'
    MAIL_PORT = 587
    MAIL_USE_TLS = True
    MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
    MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
    SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URI') or \
                              'mysql+mysqlconnector://knowage:123456@39.99.40.157/knowage?charset=utf8&auth_plugin=mysql_native_password'


class TestingConfig(BaseConfig):
    TESTING = False
    SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URI') or \
                              'mysql+mysqlconnector://knowage:123456@39.99.40.157/knowage?charset=utf8&auth_plugin=mysql_native_password'


class ProductionConfig(BaseConfig):
    SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URI') or \
                              'mysql+mysqlconnector://knowage:123456@127.0.0.1/knowage?charset=utf8&auth_plugin=mysql_native_password'

config = {
    'development': DevelopmentConfig,
    'testing': TestingConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
}
